const Koa = require('koa');
const http = require('http');
const path = require('path');
const static = require('koa-static');
const router = require('./router');
// const socket = require('./socket');
const cors = require('./middleware/cors');
const parser = require('./middleware/parser');
const error = require('./middleware/error');
const app = new Koa();
const server = http.createServer(app.callback());
// const io = require('socket.io')(server);

// socket(io);

app.use(cors());
app.use(static(path.join(__dirname, '../public')));
app.use(parser());
app.use(error());
app.use(router.routes());
app.use(router.allowedMethods());

server.listen(8080, () => {
  console.log('server is running 8080')
})
